package model

import (
	"gincli/lib"
)

func (u *User) GetOne(id uint) *User {
	db := lib.InitGorm()
	db.AutoMigrate(&User{})

	db.Raw("SELECT * FROM users WHERE id = ? and deleted_at is null", id).Scan(&u)
	return u
}

func (u User) ListUsers(ids []int) []*User {
	db := lib.InitGorm()
	db.AutoMigrate(&User{})
	var users []*User
	//db.Raw("select * from users where deleted_at is null and id in (?)").Scan(&users)
	db.Table("users").Where("id in ?", ids).Where("deleted_at is null").Find(&users)
	return users
}
